package com.mob.tools.gui;

public class CachePool<K, V>
{
  private int capacity;
  private Node<K, V> head;
  private int size;
  private Node<K, V> tail;

  public CachePool(int paramInt)
  {
    this.capacity = paramInt;
  }

  public void clear()
  {
    try
    {
      this.tail = null;
      this.head = null;
      this.size = 0;
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  public V get(K paramK)
  {
    try
    {
      Node localNode = this.head;
      Object localObject2;
      if ((localNode == null) || (localNode.key.equals(paramK)))
      {
        localObject2 = null;
        if (localNode != null)
          if (localNode.previous != null)
          {
            if (localNode.next != null)
              break label107;
            localNode.previous.next = null;
            this.tail = this.tail.previous;
          }
      }
      while (true)
      {
        localNode.previous = null;
        localNode.next = this.head;
        this.head.previous = localNode;
        this.head = localNode;
        localObject2 = localNode.value;
        return localObject2;
        localNode = localNode.next;
        break;
        label107: localNode.previous.next = localNode.next;
        localNode.next.previous = localNode.previous;
      }
    }
    finally
    {
    }
  }

  public boolean put(K paramK, V paramV)
  {
    if (paramK != null);
    boolean bool;
    Node localNode;
    try
    {
      int i = this.capacity;
      if (i <= 0)
      {
        bool = false;
        return bool;
      }
      localNode = null;
      while (this.size >= this.capacity)
      {
        localNode = this.tail;
        this.tail = this.tail.previous;
        this.tail.next = null;
        this.size = (-1 + this.size);
      }
    }
    finally
    {
    }
    if (localNode == null)
      localNode = new Node(null);
    Node.access$102(localNode, System.currentTimeMillis());
    localNode.key = paramK;
    localNode.value = paramV;
    localNode.previous = null;
    localNode.next = this.head;
    if (this.size == 0)
      this.tail = localNode;
    while (true)
    {
      this.head = localNode;
      this.size = (1 + this.size);
      bool = true;
      break;
      this.head.previous = localNode;
    }
  }

  public int size()
  {
    return this.size;
  }

  public void trimBeforeTime(long paramLong)
  {
    try
    {
      int i = this.capacity;
      if (i <= 0);
      while (true)
      {
        return;
        for (Node localNode = this.head; localNode != null; localNode = localNode.next)
          if (localNode.cacheTime < paramLong)
          {
            if (localNode.previous != null)
              localNode.previous.next = localNode.next;
            if (localNode.next != null)
              localNode.next.previous = localNode.previous;
            if (localNode.equals(this.head))
              this.head = this.head.next;
            this.size = (-1 + this.size);
          }
      }
    }
    finally
    {
    }
  }

  private static class Node<K, V>
  {
    private long cacheTime;
    public K key;
    public Node<K, V> next;
    public Node<K, V> previous;
    public V value;
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.mob.tools.gui.CachePool
 * JD-Core Version:    0.6.2
 */